﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using HCCommon;
using HCMessage.Model;
using System.Data.SqlClient;

namespace HCData
{
    public class ReportHandler
    {
        //public List<ItemReportDetail> GetItemDetailList()
        //{
        //    var result = new List<EnvCategory>();
        //    using (var con = new SqlConnection(DBConnection.GetConnection().ConnectionString))
        //    {
        //        con.Open();
        //        var cmd = con.CreateCommand();
        //        cmd.CommandText = "SELECT * FROM DBO.HC_ENV";
        //        cmd.CommandType = CommandType.Text;
        //        var reader = cmd.ExecuteReader();
        //        while (reader.Read())
        //        {
        //            result.Add(new EnvCategory
        //            {
        //                EnvCode = DBNull.Value == reader["ENV_CD"] ? "" : reader["ENV_CD"].ToString(),
        //                EnvName = DBNull.Value == reader["ENV_NM"] ? "" : reader["ENV_NM"].ToString()
        //            });
        //        }
        //    }
        //    return result;
        //}

        public void InsertItemReport(ItemReportDetail entity)
        {
            using (var con = new SqlConnection(DBConnection.GetConnection().ConnectionString))
            {
                con.Open();
                var cmd = con.CreateCommand();
                cmd.CommandText = "DBO.HC_ITEM_REPORT_UPDATE";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter { ParameterName = "@ITEM_DETAIL_ID", Value = entity.ItemDetailId, Direction = ParameterDirection.Input });
                cmd.Parameters.Add(new SqlParameter { ParameterName = "@HC_ITEM_STATU", Value = entity.Status, Direction = ParameterDirection.Input });
                cmd.Parameters.Add(new SqlParameter { ParameterName = "@REPORT_GUID", Value = entity.Guid, Direction = ParameterDirection.Input });
                cmd.Parameters.Add(new SqlParameter { ParameterName = "@HC_ITEM_REPORT_DESC", Value = entity.Desc, Direction = ParameterDirection.Input });
                cmd.Parameters.Add(new SqlParameter { ParameterName = "@USR_CRTN_ID", Value = "zhenwu", Direction = ParameterDirection.Input });
                cmd.Parameters.Add(new SqlParameter { ParameterName = "@HC_ITEM_REPORT_ID", Value = 0, Direction = ParameterDirection.Output });
                cmd.ExecuteNonQuery();
            }
   
        }

    }
}
